import 'package:flutter/material.dart';
import 'package:im_flutter_sdk/im_flutter_sdk.dart';
import 'package:open_filex/open_filex.dart';
import 'package:qunaimedical/utils/common_util.dart';

class ChatFileBubble extends StatelessWidget {
  ChatFileBubble(this.body);
  final EMFileMessageBody body;
  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () async {
        OpenFilex.open(body.localPath);
      },
      child: Container(
        color: Color.fromARGB(255, 196, 224, 246),
        width: 250,
        height: 80,
        padding: EdgeInsets.symmetric(horizontal: 16),
        child: Row(
          children: [
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(
                    body.displayName ?? "未知文件名",
                    maxLines: 2,
                    style: TextStyle(overflow: TextOverflow.ellipsis),
                  ),
                  Text(
                    CommonUtil.getDataSize(body.fileSize),
                    style: Theme.of(context).textTheme.caption,
                  ),
                ],
              ),
            ),
            Image.asset(
              'images/chat_input_more_file.png',
              width: 40,
              height: 40,
              color: Colors.orange,
            )
          ],
        ),
      ),
    );
  }
}
